<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../css/recipe.css" />
<script>
	function checkRecipe(forms) {
		var flag = false;
		var var1 = forms.elements[1].value;
		var var2 = forms.elements[3].value;
		var var3 = forms.elements[5].value;
		var var4 = forms.elements[7].value;
		var var5 = forms.elements[9].value;
		if (/(^(\d+)$|^(\d+)\.(\d+)$)/.test(var1)
				&& /(^(\d+)$|^(\d+)\.(\d+)$)/ig.test(var2)
				&& /(^(\d+)$|^(\d+)\.(\d+)$)/ig.test(var3)
				&& /(^(\d+)$|^(\d+)\.(\d+)$)/ig.test(var4)
				&& /(^(\d+)$|^(\d+)\.(\d+)$)/ig.test(var5))
			flag = true;
		else
			alert("输入数据格式不对!");
		return flag;
	}
</script>
<title>Insert title here</title>
</head>
<c:if test="${pass==null}">
	<c:redirect url="http://localhost:8080/health/login.htm" />
</c:if>
<body>
	<table>

		<tr>
			<td width="220px">
				<div class="menu">

					<a href="http://localhost:8080/health/jsp/home.jsp">首页</a><br /> <br />
					<a href="http://localhost:8080/health/jsp/BMI_Number.jsp">身高体重指数</a><br />
					<br /> <a href="http://localhost:8080/health/jsp/recipe.jsp">食谱分析</a><br />
					<br /> <a href="http://localhost:8080/health/jsp/energyCount.jsp">能量收</a><a
						href="http://localhost:8080/health/jsp/energyCount.jsp">支</a><br />
					<br /> <a href="http://localhost:8080/health/exit.do">退出登录</a>

				</div>
			</td>
			<td width="1200px">
				<h2>请选择您的食谱组成</h2>
				<h4>注:为了更符合实际,上等/劣等食材应输入实际质量的1.1/0.9倍</h4>
				<form action="recipe.do" accept-charset="utf-8"
					onsubmit="return checkRecipe(this)">
					<table>

						<tr>
							<td>主食:<select name="staple_food">
									<option value="大米" selected="selected">大米</option>
									<option value="面条">面条</option>
									<option value="馒头">馒头</option>
									<option value="小米">马铃薯</option>
							</select></td>
							<td><input type="text" id="count1" name="mainCount"
								value="0">g</td>
						<tr>
							<td>肉类:<select name="meat">
									<option value="猪肉">猪肉</option>
									<option value="2">狗肉</option>
									<option value="3">牛肉</option>
									<option value="4">羊肉</option>
									<option value="5">鸡肉</option>
									<option value="6">鱼肉</option>
									<option value="7">五花肉</option>
							</select> <!-- 肉类:<select name="quality">
											<option value="1">上等</option>
											<option value="2" selected="selected">中等</option>
											<option value="3">劣等</option>
									</select>
 -->
							</td>
							<td><input type="text" name="meatCount" value="0">g</td>
						<tr>
							<td>蔬菜:<select name="leaf">
									<option value="白菜">白菜</option>
									<option value="7">空心菜</option>
									<option value="8">油麦菜</option>
									<option value="7">韭菜</option>
									<option value="7">西兰花</option>
									<option value="7">白菜花</option>
									<option value="7">韭菜</option>
							</select></td>
							<td><input type="text" name="leafCount" value="0">g</td>
						<tr>
						<tr>
							<td>配菜:<select name="other">
									<option value="鸡蛋">鸡蛋</option>
									<option value="8">油麦菜</option>
									<option value="7">韭菜</option>
									<option value="8">白菜</option>
									<option value="7">西兰花</option>
									<option value="7">白菜花</option>
									<option value="7">韭菜</option>
							</select></td>
							<td><input type="text" name="otherCount" value="0">g</td>
						<tr>
							<td>水果:<select name="melon">
									<option value="苹果">苹果</option>
									<option value="2">猕猴桃</option>
									<option value="3">南瓜</option>
									<option value="4">丝瓜</option>
									<option value="5">黄瓜</option>
									<option value="6">菜瓜</option>
									<option value="7">甜椒</option>
									<option value="8">茄子</option>
							</select></td>
							<td><input type="text" name="melonCount" value="0">g</td>
						</tr>
						<tr>
							<td><input type="submit" name="submit" /></td>
						</tr>

					</table>
				</form>
				<p></p> <br />
				<table class="page" style="border: 1px solid;">

					<tr>
						<th>&nbsp;</th>
						<th>食谱名</th>
						<th>能量(kJ)</th>
						<th>蛋白质(g)</th>
						<th>脂肪(g)</th>
						<th>糖分(g)</th>
						<th>钙(g)</th>
						<th>铁(g)</th>
						<th>维生素A(mg)</th>
						<th>维生素B1(mg)</th>
						<th>维生素B2(mg)</th>
						<th>维生素C(mg)</th>
						<th>维生素D(mg)</th>
						<th>维生素E</th>
					</tr>
					<tr>
						<td>每日需求</td>
						<td>&nbsp;</td>
						<tD>${pass.getWeight()*0.06*240*1.8 }</td>
						<td>50</td>
						<td>250-350</td>
						<td>12-20</td>
						<td>8</td>
						<td>1</td>
						<td>0.8-1.0</td>
						<td>1.2-1.4</td>
						<td>1</td>
						<td>75</td>
						<td>0.005</td>
						<td>140-210</td>
					</tr>
					<tr>
						<td>套餐A</td>
						<td>${nutrient.getName() }</td>
						<td>${nutrient.getEnergy() }</td>
						<td>${nutrient.getProtein() }</td>
						<td>${nutrient.getFat() }</td>
						<td>${nutrient.getSugar() }</td>
						<td>${nutrient.getCa()}</td>
						<td>${nutrient.getFe() }</td>
						<td>${nutrient.getVA() }</td>
						<td>${nutrient.getVB1() }</td>
						<td>${nutrient.getVB2() }</td>
						<td>${nutrient.getVC() }</td>
						<td>${nutrient.getVD() }</td>
						<td>${nutrient.getVE() }</td>
					</tr>
					<tr>
						<td>套餐B</td>
						<td>${nutrient2.getName() }</td>
						<td>${nutrient2.getEnergy() }</td>
						<td>${nutrient2.getProtein() }</td>
						<td>${nutrient2.getFat() }</td>
						<td>${nutrient2.getSugar() }</td>
						<td>${nutrient2.getCa()}</td>
						<td>${nutrient2.getFe() }</td>
						<td>${nutrient2.getVA() }</td>
						<td>${nutrient2.getVB1() }</td>
						<td>${nutrient2.getVB2() }</td>
						<td>${nutrient2.getVC() }</td>
						<td>${nutrient2.getVD() }</td>
						<td>${nutrient2.getVE() }</td>
					</tr>
					<tr>
						<td>套餐C</td>
						<td>${nutrient1.getName() }</td>
						<td>${nutrient1.getEnergy() }</td>
						<td>${nutrient1.getProtein() }</td>
						<td>${nutrient1.getFat() }</td>
						<td>${nutrient1.getSugar() }</td>
						<td>${nutrient1.getCa()}</td>
						<td>${nutrient1.getFe() }</td>
						<td>${nutrient1.getVA() }</td>
						<td>${nutrient1.getVB1() }</td>
						<td>${nutrient1.getVB2() }</td>
						<td>${nutrient1.getVC() }</td>
						<td>${nutrient1.getVD() }</td>
						<td>${nutrient1.getVE() }</td>
					</tr>
					<tr>
						<td>合计</td>
						<td></td>
						<td>${nutrient.getEnergy()+nutrient1.getEnergy()+nutrient2.getEnergy() }</td>
						<td>${nutrient1.getProtein()+nutrient.getProtein()+nutrient2.getProtein() }</td>
						<td>${nutrient1.getVC()+nutrient.getVC()+nutrient2.getVC() }</td>
						<td>${nutrient1.getSugar()+nutrient.getSugar()+nutrient2.getSugar() }</td>
						<td>${nutrient1.getCa()+nutrient.getCa()+nutrient2.getCa() }</td>
						<td>${nutrient1.getFe()+nutrient.getFe()+nutrient2.getFe() }</td>
						<td>${nutrient1.getVA()+nutrient.getVA()+nutrient2.getVA() }</td>
						<td>${nutrient1.getVB1()+nutrient.getVB1()+nutrient2.getVB1() }</td>
						<td>${nutrient1.getVB2()+nutrient.getVB2()+nutrient2.getVB2() }</td>
						<td>${nutrient1.getVC()+nutrient.getVC()+nutrient2.getVC() }</td>
						<td>${nutrient1.getVD()+nutrient.getVD()+nutrient2.getVD() }</td>
						<td>${nutrient1.getVE()+nutrient.getVE()+nutrient2.getVE() }</td>
					</tr>

				</table>
				<p>&nbsp;</p> <br> <a href="recipeAjax.do?submit=reset"><button>重置</button></a>

			</td>
		</tr>

	</table>
</body>
</html>